//
//  GoodShopTopView.m
//  BTRIP
//
//  Created by johnbk on 15/11/13.
//  Copyright © 2015年 johnbk. All rights reserved.
//

#import "GoodShopTopView.h"
#import <SDWebImageManager.h>
#import <UIImageView+WebCache.h>
@implementation GoodShopTopView

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/
-(void)dealloc{
	[_detailGoodShopModel release];
	[_imgView release];
	[_labelOfName release];
	[_labelOfSlogan release];
	[_labelOfUserNickName release];
	[_imageViewOfUserAvatar release];
	[super dealloc];
}
-(instancetype)initWithFrame:(CGRect)frame{
	self = [super initWithFrame:frame];
	if (self) {
		[self createView];
	}
	return self;
}
- (void)createView{
	self.imgView = [[UIImageView alloc]init];
	[self addSubview:self.imgView];
	[self.imgView release];
	self.labelOfName = [[UILabel alloc]init];
	[self addSubview:self.labelOfName];
	[self.labelOfName release];
	self.labelOfSlogan = [[UILabel alloc]init];
	[self addSubview:self.labelOfSlogan];
	[self.labelOfSlogan release];
	self.imageViewOfUserAvatar = [[UIImageView alloc]init];
	[self addSubview:self.imageViewOfUserAvatar];
	[self.imageViewOfUserAvatar release];
	self.labelOfUserNickName = [[UILabel alloc]init];
	[self addSubview:self.labelOfUserNickName];
	[self.labelOfUserNickName release];
	
}
-(void)layoutSubviews{
	[super layoutSubviews];
	//self.backgroundColor = [UIColor cyanColor];
	self.imgView.frame = CGRectMake(0, 0, self.frame.size.width, 250);
	self.labelOfName.frame = CGRectMake(0, 0, 200, 30);
	//self.labelOfName.backgroundColor = [UIColor purpleColor];
	self.labelOfName.center = CGPointMake(self.frame.size.width / 2, self.imgView.frame.origin.y + self.imgView.frame.size.height + 35);
	self.labelOfName.textAlignment = NSTextAlignmentCenter;
	self.labelOfName.font = [UIFont systemFontOfSize:16];
	self.labelOfSlogan.frame = CGRectMake(0, 0, self.frame.size.width,30);
	self.labelOfSlogan.center = CGPointMake(self.labelOfName.center.x, self.labelOfName.center.y + 30);
	//self.labelOfSlogan.backgroundColor = [UIColor brownColor];
	self.labelOfSlogan.textAlignment = NSTextAlignmentCenter;
	self.labelOfSlogan.font = [UIFont systemFontOfSize:12];
	self.imageViewOfUserAvatar.frame = CGRectMake(20, self.labelOfSlogan.frame.origin.y + 40, 30, 30);
	self.imageViewOfUserAvatar.layer.cornerRadius = self.imageViewOfUserAvatar.frame.size.width / 2;
	self.labelOfUserNickName.frame = CGRectMake(self.imageViewOfUserAvatar.frame.origin.x + self.imageViewOfUserAvatar.frame.size.width + 20, self.imageViewOfUserAvatar.frame.origin.y + 8, 100, 25);
	//self.labelOfUserNickName.backgroundColor = [UIColor redColor];
	self.labelOfUserNickName.font = [UIFont systemFontOfSize:12];
	self.labelOfUserNickName.textColor = [UIColor darkGrayColor];
}
- (void)setDetailGoodShopModel:(DetailGoodShopModel *)detailGoodShopModel{
	if (_detailGoodShopModel != detailGoodShopModel) {
		[_detailGoodShopModel release];
		_detailGoodShopModel = [detailGoodShopModel retain];
		[self.imgView sd_setImageWithURL:[NSURL URLWithString:detailGoodShopModel.url] placeholderImage:[UIImage imageNamed:@"background"]];
		self.labelOfName.text = detailGoodShopModel.name;
		self.labelOfSlogan.text = [NSString stringWithFormat:@"-----  %@  -----", detailGoodShopModel.slogan];
		[self.imageViewOfUserAvatar sd_setImageWithURL:[NSURL URLWithString:detailGoodShopModel.user_avatar] placeholderImage:[UIImage imageNamed:@"background"]];
		self.labelOfUserNickName.text = detailGoodShopModel.user_nickname;
		
	}
}
@end
